package cn.tedu.luban.settle.main.consumer;

import cn.tedu.luban.order.protocol.dto.OrderMessageDTO;
import cn.tedu.luban.settle.main.service.SettleSevice;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RocketMQMessageListener(
        topic = "order_finish_topic",
        consumerGroup = "settle-group"
)
@Component
public class SettleFinishConsumer implements RocketMQListener<OrderMessageDTO> {

    @Autowired
    private SettleSevice settleSevice;

    @Override
    public void onMessage(OrderMessageDTO orderMessageDTO) {
        //调用业务层，计算账单，存储账单
        try {
            settleSevice.settle(orderMessageDTO);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
